package com.kgc.vod.controller;


import com.kgc.common.result.Result;
import com.kgc.vod.service.VideoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("vod/video")
public class VodController {


    private final VideoService videoService;

    public VodController(VideoService videoService) {
        this.videoService = videoService;
    }

    @PostMapping("upload")
    public Result upload(MultipartFile file) {
        String videoId = videoService.upload(file);
        return Result.ok().setData("item", videoId);
    }

    @DeleteMapping("{id}")
    public Result delVideoById(@PathVariable String id) {
        videoService.delVideoById(id);
        return Result.ok();
    }
}
